package com.kehongborui.spring.service;

import com.kehongborui.spring.dao.UserDao;
import com.kehongborui.spring.dao.impl.MysqlUserDao;
import com.kehongborui.spring.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;

/**
 * @author zhang peng yang ming
 * @CopyRight (C) http://www.csdn.com
 * @brief
 * @email 122162005@qq.com
 * @date 2018-07-31
 */
@Service // 配置业务层自动扫描组件
public class LoginService {
//    @Resource
//    @Qualifier("mysqlUserDao")
    @Inject
    @Qualifier("mysqlUserDao")
    private UserDao userDao;

    public LoginService() {
        System.out.println("构造方法");
    }
    public User findByUsername(String username) {
        User user = userDao.findByUsername("username");
        return user;
    }

    @PostConstruct
    public void init() {
        System.out.println("LoginService被初始化");
    }

    @PreDestroy  // 在对象被销毁的时候回调此方法
    public void destroy() {
        System.out.println("LoginService被销毁");
    }
}
